<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Admin Template </title>
<%@ include file="include.jsp"%>

	<script type="text/javascript">
    $(document).ready(function() {
    
       $("#tabs").tabs();
        $('#uploadify').uploadify({
            'uploader': '/adminpanel/img/uploadify.swf',
            'script'  : '/adminpanel/uploadfiles;jsessionid=<%=session.getId()%>',
            //'folder': '/adminpanel/img/',
            //'fileDataName':'fileDate', 
            'multi': true,
            'auto': false,
            'fileDesc' : '*.jpg;*.gif;*.png;*.rar;*.doc;*.pdf',   
    		'fileExt'  : '*.jpg;*.gif;*.png;*.rar;*.doc;*.pdf',   
            //'rollover':true,
            'cancelImg': '/adminpanel/img/cancel.png',
           	'onError' : function(event, queueID, fileObj, errorObj) {
				alert(errorObj.type + "Error:" + errorObj.info);
		    },
		  
			'onComplete': function(event, queueID, fileObj, reposnse, data) {
				$('#result').append('<a href='+fileObj.filePath+'>'+fileObj.name+'</a><br>');
				window.location.reload();
				
			}
		});
		
		$('#hiddenresult').load('http://localhost:8080/adminpanel/myinfo/ufiles', null, initPagination);

	});
	
	
	function pageselectCallback(page_index, jq){
           var new_content = $('#hiddenresult div.colgroup:eq('+page_index+')').clone();
           for(var i=0;i<${usercountfiles};i++){
           		$('#searchresult').empty().append(new_content[i]);
           }
           
           return false;
	 }
	
	
	 function initPagination() {
         //var num_entries = $('#hiddenresult div.result').length;
         
         $("#Pagination").pagination(${usercountfiles}, {
             num_edge_entries: 2,
             num_display_entries: 5,
             items_per_page:5,
             callback: pageselectCallback
             
             
         });
     }
     
     	

	function uploadFile() {//上传文件

		jQuery('#uploadify').uploadifyUpload();
		//return false;
	}

	function showResult() {//删除显示的上传成功结果
		$("#result").html("");
	}
</script>
	
	</head>
<body>


	<%@ include file="header.jsp"%>
	<!-- Page content -->
	<div id="page">
		<!-- Wrapper -->
		<div class="wrapper">
				<!-- Left column/section -->
				<section class="column width6 first">					

					<h3>Uploaded Files</h3>
					
					<div id="tabs">
						<ul>
							<li><a class="corner-tl" href="#tabs-date">List by date</a></li>
							<li><a class="corner-tr" href="#tabs-abc">List by alphabet</a></li>
						</ul>
						<div id="tabs-date">
							<div class="colgroup">
								<div class="width3 column first">
									<p>Showing <b>1-5</b> of <b>${usercountfiles}</b> results</p>
								</div>
								<div class="width3 column">
									<p class="pagination ta-right">
										<div id="Pagination"></div>
									</p>
								</div>
							</div>
							<div class="clearfix"></div>
							<hr />
							
								<div id="searchresult">
										
								</div>
							
							 <div id="hiddenresult" style="display:none;">
        						
       						 </div>
							
							
							
							
							<div class="clearfix"></div>
							
							</div>
						
					</div> 

				</section>
				<!-- End of Left column/section -->
				
				<!-- Right column/section -->
				<aside class="column width2">
					<p class="leading"><input id="uploadify" name="uploadify" type="file"  /></p>
					<form:form modelAttribute="uploadBean" method="post" enctype="multipart/form-data">
						
         			</form:form>
					<p><a href="javascript:uploadFile()">Start Upload</a></p>
					<div id="result"></div>
				
				</aside>
				<!-- End of Right column/section -->
				
		</div>
		<!-- End of Wrapper -->
	</div>
	<!-- End of Page content -->
	
	<%@ include file="footer.jsp"%>

</body>
</html>
